package com.ggy.tuibi.Schedu;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author guoguangyuan
 * @Date 2025/4/4
 */
public class XingKongQuWan {

    public static void main(String[] args) {
        XingKongQuWan service = new XingKongQuWan();
        ExecutorService executorService = Executors.newCachedThreadPool();
        List<Runnable> taskList = new ArrayList<>();
        String token1 = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImZmM2U0NWFmLTNhMTAtNGI1MC04Njg0LWNlZWY5NDljNWY0NSJ9.Pgt5m-myCfEeATCRbCJC1ne0VgAzRaPkHxckXg-29SUL6p_c70lqf6gL0pL9wSYZyd3wHCNpeNiyGDjGhXsLBw";
        String token2 = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImIxMWIyYjNhLTYwM2ItNDA3Yy04NzQ1LWM2ZDllMmI3YTRlZiJ9.Kq4MnTy9d8XDAPJ4MnoXDwEnxpYhe7Wq4IYR7TX0D53uXIHam9asrf0UHOPSKXyDLOylzVFpqFRSgxkB6dtVUQ";
        for (int i = 0; i < 50; i++) {
            if (i%2==0){
                taskList.add(() -> service.xiaji(token1));
            }else {
                taskList.add(() -> service.xiaji(token2));
            }
        }
        for (Runnable runnable : taskList) {
            executorService.submit(runnable);
        }

        executorService.shutdown();
    }

    private void duihuan() {

        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("Authorization", "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImIxMWIyYjNhLTYwM2ItNDA3Yy04NzQ1LWM2ZDllMmI3YTRlZiJ9.Kq4MnTy9d8XDAPJ4MnoXDwEnxpYhe7Wq4IYR7TX0D53uXIHam9asrf0UHOPSKXyDLOylzVFpqFRSgxkB6dtVUQ");
        headerMap.put("appName", "com.arrayinfo.toygrap");
        headerMap.put("appVersion", "2.5.1");
        headerMap.put("User-Agent", "okhttp/3.12.13");

        Map<String, Object> bodyMap = new HashMap<>();
        bodyMap.put("appVersion", "2.5.1");
        bodyMap.put("osVersion", "9");
        bodyMap.put("src", "pdd");
        bodyMap.put("osType", "2");
        bodyMap.put("dname", "V1824A");
        bodyMap.put("type", "arc");
        bodyMap.put("deviceId", "9821b932f99a54376031d8381ea32c0f513f989d");
        bodyMap.put("platform", "2");
        bodyMap.put("coin", 18000);

        HttpRequest request = HttpUtil.createPost("https://mapi.wowpdd.com/v1/points/exchange?osType=2&gps=0%2C0&src=pdd&dname=V1824A&deviceId=9821b932f99a54376031d8381ea32c0f513f989d&appVersion=2.5.1&osVersion=9&platform=2");
        request.addHeaders(headerMap);
        request.body(JSONUtil.toJsonStr(bodyMap));
        HttpResponse response = request.execute();
        System.out.println(response.body());
    }

    private void xiaji(String token) {
        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("Authorization", token);
        headerMap.put("appName", "com.arrayinfo.toygrap");
        headerMap.put("appVersion", "2.5.1");
        headerMap.put("User-Agent", "okhttp/3.12.13");


        Map<String, Object> bodyMap = new HashMap<>();
        bodyMap.put("appVersion", "2.5.1");
        bodyMap.put("positionId", 352);
        bodyMap.put("osVersion", "9");
        bodyMap.put("src", "pdd");
        bodyMap.put("osType", "2");
        bodyMap.put("dname", "V1824A");
        bodyMap.put("deviceId", "9821b932f99a54376031d8381ea32c0f513f989d");
        bodyMap.put("roomId", 193);
        bodyMap.put("platform", "2");
        HttpResponse response = HttpUtil.createPost("https://mapi.wowpdd.com/v1/settlement?osType=2&gps=0%2C0&src=pdd&dname=V1824A&deviceId=9821b932f99a54376031d8381ea32c0f513f989d&appVersion=2.5.1&osVersion=9&platform=2")
                .body(JSONUtil.toJsonStr(bodyMap))
                .addHeaders(headerMap)
                .execute();
        System.out.println(response.body()+"\n"+token);
    }
}
